extern "C" {
#include "apue.h"
}


#include <stdio.h>
#include <dirent.h>

int  main(int argc,char** argv)
{
	// show your argv
	#if(0)
	char** p=argv;
	p++;
	int i=0;
	while(*p!=nullptr)
		printf("argv[%d]=%s\n",++i,*p++);	
	#endif

	DIR *dp;
	struct dirent *dirp;
	if (argc != 2)
	err_quit("usage: ls directory_name");
	if ((dp = opendir(argv[1])) == NULL)
	err_sys("can’t open %s", argv[1]);
	while ((dirp = readdir(dp)) != NULL)
		printf("%s ", dirp->d_name);
	
	closedir(dp);
	exit(0);



	return 0;

}
